<?php
/*
 * @ https://EasyToYou.eu - IonCube v11 Decoder Online
 * @ PHP 7.2 & 7.3
 * @ Decoder version: 1.1.6
 * @ Release: 10/08/2022
 */

// Decoded file for php version 71.
namespace app\admin\model;

class CoreAttachment extends \app\BaseModel
{
    protected $name = "shequshop_school_attachment";
    public function searchIdsAttr($query, $ids, $data)
    {
        $query->where("id", "in", $ids);
    }
    public function createAttach($data)
    {
        $data["module_upload_dir"] = 0;
        $data["displayorder"] = 0;
        $data["group_id"] = !empty($data["group_id"]) ? $data["group_id"] : 0;
        $result = $this->save($data);
        $result = !empty($result);
        return $result;
    }
    public function updateAttach($filter, $data)
    {
        $result = $this->where($filter)->update($data);
        $result = !empty($result);
        return $result;
    }
    public function listAttach($filter, $page_config)
    {
        $start_row = ($page_config["page"] - 1) * $page_config["page_count"];
        $end_row = $page_config["page_count"];
        $result = $this->where($filter)->order("createtime", "desc")->limit($start_row, $end_row)->select();
        if(!empty($result)) {
            $result = $result->toArray();
        }
        return $result;
    }
    public function listAttachCount($filter)
    {
        $result = $this->where($filter)->count();
        return $result;
    }
    public function addAttach($data)
    {
        $data["module_upload_dir"] = 0;
        $result = $this->insert($data);
        return $result;
    }
    public function getAttach($filter)
    {
        $result = $this->where($filter)->find();
        if(!empty($result)) {
            $result = $result->toArray();
        }
        return $result;
    }
    public function delAttach($filter)
    {
        return $this->destoryAttach($filter);
    }
    public function destoryAttach($filter)
    {
        $result = $this->withSearch(["ids"], $filter)->delete();
        return !empty($result);
    }
}

?>